//获取手机号
var username = document.getElementsByClassName("zhuce-one-inp")[0];
var usertext = document.getElementsByClassName("zhuce-two")[0];
//验证码输入框
var yanz = document.getElementsByClassName("zhuce-three-inp")[0];
//获取验证码
var yanzma = document.getElementsByClassName("zhuce-three-btn")[0];
//获取密码
var poss = document.getElementsByClassName("zhuce-five-inp")[0];
var posstext = document.getElementsByClassName("zhuce-six")[0];
//再次获取密码
var possw = document.getElementsByClassName("zhuce-sevent-inp")[0];
var posswtext = document.getElementsByClassName("zhuce-eight")[0];
//获取注册按钮
var btnz = document.getElementsByClassName("but1")[0];
//验证手机号
var number1 = /^1[3|4|5|8][0-9]\d{4,8}$/;
var num = 0;
var timer = null;
//验证手机号
btnz.onclick=function(){
	var flag = true;
	if(username.value == ""){
		usertext.innerHTML = "手机号不能为空";
		flag = false;
	}else if(!/^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$/.test(username.value)){
		usertext.innerHTML = "仅支持中英文、数字或者下划线";
		flag = false;
	}else{
		usertext.innerHTML = "";
	}
//验证密码	
	if(poss.value == ""){
		posstext.innerHTML = "密码不能为空";
		flag = false;
	}else if(!/^[A-Za-z0-9_]+$/.test(poss.value)){
		posstext.innerHTML = "密码仅支持英文、数字或者下划线";
		flag = false;
	}else{
		posstext.innerHTML = "";
	}
//验证确认密码
	if(possw.value == ""){
		posswtext.innerHTML = "密码不能为空";
		flag = false;
	}
	else if(possw.value != poss.value){
		posswtext.innerHTML = "两次密码不同";
		flag = false;
	}else{
		posswtext.innerHTML = "";
	}
//如果没问题，提交数据	
 
	if(flag == true) {
//	window.location.href = "denglu.html";
		alert("提交中。。。")
		$('.enroll').hide();
		$('.register').show();
		var local = window.localStorage;
		local.user = $('.zhuce-one-inp').val();
		local.past = $('.zhuce-five-inp').val();
	}
}

//验证码
var num = 0;
var intager = null;
yanzma.onclick = function(){
	clearInterval(intager)
	intager = setInterval(function(){
		num ++;
		yanzma.value = "已发送" +"(" +(60-num)+")";
		if(num == 60){
			clearInterval(intager)
			yanzma.value = "重新发送";
			num = 0;
		}
	},1000)
}

